/*
    This file is part of Posixcpp library.

    Posixcpp library is free software: you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public License
    as published by the Free Software Foundation, either version 3 of
    the License, or (at your option) any later version.

    Posixcpp library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU LesserGeneral Public
    License along with Posixcpp library. If not, see
    <http://www.gnu.org/licenses/>.
 */

#ifndef POSIX_PROCESSES_PROCESS_HPP
#define	POSIX_PROCESSES_PROCESS_HPP

#include "posixcpp_activeobject.hpp"

namespace posix {
namespace processes {

/**
 * @class Process
 * @brief Class, representing the POSIX process
 */
class Process : public posixcpp::ActiveObject {
public:
    Process ();
    Process (pid_t pid);
    virtual ~Process ();
    
    /**
     * @property handle
     * @brief Native process handle (e.g. Linux pid_t)
     */
    
    pid_t handle() const {
        return m_pid;
    }
    
    pid_t &handle() {
        return m_pid;
    }
    
    /**
     * @brief the process
     */
    void start();
    /**
     * @brief send a signal to the process
     * @param signo signal number to send
     * @return 
     */
    int kill(int signo);
    
    static Process self();
    
    int wait( int options = 0 );
    
    posixcpp::ActiveObject::ExecutionsRes_t waitFinish() override;

    
private:
    pid_t m_pid;
};

}
}

#endif	/* POSIX_PROCESSES_PROCESS_HPP */
